package w5

//可以加属性
trait BlueBooth {
  var dist: Double = 200

  def connect(): Unit = {
    println("设备通过了蓝牙来通信")
  }
}

trait RedOut {
  def conn(): Unit = {
    println("设备通过红外连接")
  }

  def close()
}

class Camera(brand: String, price: Double) {
  def takePhoto(scene: String): Unit = {
    println(s"${brand}给${scene} 拍了一张照片")
  }
}

class DigitalCamera(brand: String, price: Double) extends Camera(brand, price) with BlueBooth with RedOut {
  override def takePhoto(scene: String): Unit = {
    println(s"${brand}给${scene} 拍了一张高清照片")
  }

  override def connect() {
    println(s"${brand}相机用蓝牙和外部设备连接上了")
  }

  override def close(): Unit = {
    println(s"${brand}相机断开了连接")
  }

  def ontimeTake(time: Int): Unit = {
    println(s"${brand}相机在过了${time}秒后自动拍了一张照片")
  }
}

object DigitalCamera {
  def main(args: Array[String]): Unit = {
    val c = new DigitalCamera("海鸥牌", 1999)
    c.dist = 199
    println(c.dist + "米是蓝牙的有效距离")
    c.takePhoto("小朱")
    c.connect()
    c.conn()

    c.ontimeTake(10)
    c.close()
  }
}
